<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" href="docgen-resources/docgen.css" type="text/css">
  <meta name="generator" content="FreeMarker Docgen (DocBook 5)">
  <title>
    FreeMarker Manual - global
  </title>
    <script type="text/javascript" src="docgen-resources/jquery.js"></script>
    <script type="text/javascript" src="docgen-resources/linktargetmarker.js"></script>
</head>
<body>

    <div class="navigation">
    <div class="breadcrumb">
<span class="breadcrumb">        You are here:
          <a href="index.html">Book</a>
            <b>></b>
          <a href="ref.html">Reference</a>
            <b>></b>
          <a href="ref_directives.html">Directive Reference</a>
            <b>></b>
          global
</span>    </div>
    <div class="bookmarks">
<span class="bookmarks">Bookmarks:
<a href="alphaidx.html">Alphabetical Index</a>, <a href="gloss.html">Glossary</a>, <a href="ref.html">Reference</a>, <a href="app_faq.html">FAQ</a>, <a href="api/index.html">Java API</a>, <a href="../index.html">FreeMarker Home</a></span>    </div>
    <div class="pagers">
      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
<div class="pagerButton"><a href="ref_directive_local.html"><span class="hideA">Next page: </span>local</a></div><div class="pagerButton"><a href="ref_directive_assign.html">Previous page</a></div><div class="pagerButton"><a href="ref_directives.html">Parent page</a></div><div class="pagerButton"><a href="index.html">Contents</a></div>      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
    </div>
    </div>

<div id="mainContent">

  
  
  
  
  <h1 class="rank_section1"
        id="pageTopTitle">
<a name="ref_directive_global"></a>global  </h1>
    
    <div class="toc">
      <p>
        <b>
            Page Contents
        </b>
      </p>
      
  <ul class="noMargin">
      <li>
        <a href="#autoid_96">Synopsis</a>
      </li>
      <li>
        <a href="#autoid_97">Description</a>
      </li>
  </ul>
    </div>
    <a name="docgen_afterTheTOC"></a>
    
<a name="ref.directive.global"></a>
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="autoid_96"></a>Synopsis  </h2>


          <pre class="metaTemplate">
<tt style="color: #A03D10">&lt;#global <i style="color: #DD4400">name</i>=<i style="color: #DD4400">value</i>&gt;</tt>
or
<tt style="color: #A03D10">&lt;#global <i style="color: #DD4400">name1</i>=<i style="color: #DD4400">value1</i> <i style="color: #DD4400">name2</i>=<i style="color: #DD4400">value2</i> <i style="color: #DD4400">... nameN</i>=<i style="color: #DD4400">valueN</i>&gt;</tt>
or
<tt style="color: #A03D10">&lt;#global <i style="color: #DD4400">name</i>&gt;
  <i style="color: #DD4400">capture this</i>
&lt;/#global&gt;</tt>
</pre>


          <p>Where:</p>

              <div class="itemizedlist">
<ul>
            <li>
              <tt style="color: #A03D10"><i style="color: #DD4400">name</i></tt>: name
              of the variable. It is not expression. However, it can be
              written as a string literal, which is useful if the variable
              name contains reserved characters, for example
              <tt style="color: #A03D10">&lt;#global &quot;foo-bar&quot; = 1&gt;</tt>. Note that this
              string literal does not expand interpolations (as
              <tt style="color: #A03D10">&quot;${foo}&quot;</tt>).
            </li>

            <li>
              <tt style="color: #A03D10"><i style="color: #DD4400">value</i></tt>: the
              value to store. Expression.
            </li>
          </ul>    </div>

        
            
  
  
  
  <h2 class="rank_section2"
        >
<a name="autoid_97"></a>Description  </h2>


          <p>This directive is similar to <a href="ref_directive_assign.html#ref.directive.assign"><tt>assign</tt></a>, but
          the variable created will be visible in all <a href="dgui_misc_namespace.html">namespaces</a>, and will not be
          inside any namespace. Exactly as if you would create (or replace) a
          variable of the data-model. Hence, the variable is global. If a
          variable with the same name already exists in the data-model, it
          will be hidden by the variable created with this directive. If a
          variable with the same name already exists in the current namespace,
          that will hide the variable created with <tt style="color: #A03D10">global</tt>
          directive.</p>

          <p>For example, with <tt style="color: #A03D10">&lt;#global x = 1&gt;</tt> you
          create a variable that is visible as <tt style="color: #A03D10">x</tt> in all
          namespaces, unless another variable called <tt style="color: #A03D10">x</tt>
          hides it (for example a variable what you have created as
          <tt style="color: #A03D10">&lt;#assign x = 2&gt;</tt>). In this case, you can use
          <a href="dgui_template_exp.html#dgui_template_exp_var_special">special
          variable</a> <tt style="color: #A03D10">globals</tt>, like
          <tt style="color: #A03D10">${.globals.x}</tt>. Note that with
          <tt style="color: #A03D10">globals</tt> you see all globally accessible
          variables; not only the variables that were created with
          <tt style="color: #A03D10">global</tt> directive, but also the variables of the
          data-model.</p>

          <p>Note for custom JSP tag users: The set of variables created
          with this directive corresponds to the JSP page-scope. This means,
          that if a custom JSP tag wants to get a page-scope attribute
          (page-scope bean), a variable with the same name in the current
          namespace will not hide it from the viewpoint of the JSP tag.</p>
          
</div>

    <div class="navigation">
    <div class="pagers">
      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
<div class="pagerButton"><a href="ref_directive_local.html"><span class="hideA">Next page: </span>local</a></div><div class="pagerButton"><a href="ref_directive_assign.html">Previous page</a></div><div class="pagerButton"><a href="ref_directives.html">Parent page</a></div><div class="pagerButton"><a href="index.html">Contents</a></div>      <div class="pagersVerticalSpacer"><img src="docgen-resources/img/none.gif" width="1" height="1" alt="" hspace="0" vspace="0" border="0"/></div>
    </div>
    <div class="breadcrumb">
<span class="breadcrumb">        You are here:
          <a href="index.html">Book</a>
            <b>></b>
          <a href="ref.html">Reference</a>
            <b>></b>
          <a href="ref_directives.html">Directive Reference</a>
            <b>></b>
          global
</span>    </div>
    </div>

<table border=0 cellspacing=0 cellpadding=0 width="100%">
    <tr>
      <td colspan=2><img src="docgen-resources/img/none.gif" width=1 height=8 alt=""></td>
    <tr>
      <td align="left" valign="top"><span class="smallFooter">
            FreeMarker Manual -- For FreeMarker 2.3.16
            <br>
          HTML generated: 2009-12-08 08:38:54 GMT
      </span></td>
      <td align="right" valign="top"><span class="smallFooter">
          <a href="http://www.xmlmind.com/xmleditor/">
            <img src="docgen-resources/img/xxe.gif" alt="Edited with XMLMind XML Editor">
          </a>
      </span></td>
    </tr>
</table>
  <!-- Put pre-loaded images here: -->
  <div style="display: none">
    <img src="docgen-resources/img/linktargetmarker.gif" alt="Here!" />
  </div>
</body>
</html>

